export default {
  // 获取用户所有的品牌
  getUserBrandList ({ commit, state }) {
    return new Promise((resolve, reject) => {
      if (Array.isArray(state.userBrandList) && state.userBrandList.length > 0) {
        resolve(state.userBrandList)
      } else {
        $vue.$api.permissionListPage({
          pageNo: 1,
          pageSize: 9999,
          data: { userId: $vue.USER_INFO.user.id }
        }).then(res => {
          if (res.list.length > 0) {
            commit('setUserBrandList', res.list)
            resolve(res.list)
          } else {
            reject(res)
          }
        }).catch(e => e)
      }
    })
  },
  // 获取投放类型级联数据
  listByLaunchTypePlatform ({ commit, state }) {
    return new Promise((resolve, reject) => {
      if (Array.isArray(state.launchTypes) && state.launchTypes.length > 0) {
        resolve(state.launchTypes)
      } else {
        $vue.$api.launchPlanListByLaunchTypePlatform().then(res => {
          if (res.length > 0) {
            commit('setLaunchTypes', res)
            resolve(res)
          } else {
            reject(res)
          }
        }).catch(e => e)
      }
    })
  }
}
